/*
 * This source code is part of TWaver 4.0
 *
 * Serva Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * Copyright 2002 - 2011 Serva Software. All rights reserved.
 */

package demo;

import java.util.HashMap;
import java.util.Map;

import twaver.Element;
import twaver.Node;
import twaver.TDataBox;
import demo.alarm.mapping.AlarmElementMappingDemo;
import demo.alarm.overview.AlarmStatisticsDemo;
import demo.chart.attachment.ChartAttachmentDemo;
import demo.chart.bubble.BubbleChartDemo;
import demo.chart.composition.CompositionDemo;
import demo.chart.dial.DialChartDemo;
import demo.chart.gdp.GDPDemo;
import demo.chart.loading.LoadingDemo;
import demo.chart.netbeans.NetbeansSurveyDemo;
import demo.chart.property.PropertyDemo;
import demo.chart.radar.RadarChartDemo;
import demo.chart.stock.GoogleStockDemo;
import demo.chart.survey.SurveyDemo;
import demo.databox.conversion.ConversionDemo;
import demo.databox.monitorelement.MonitorElementDemo;
import demo.databox.monitorproperty.MonitorPropertyDemo;
import demo.editor.chassis.ChassisEditorDemo;
import demo.editor.drawing.DrawingEditorDemo;
import demo.editor.network.NetworkEditorDemo;
import demo.editor.pipe.PipeEditorDemo;
import demo.list.choose.ChooseDemo;
import demo.list.search.QuickSearchDemo;
import demo.network.chassis.customgrid.CustomGridDemo;
import demo.network.chassis.dynamic.DynamicChassisDemo;
import demo.network.chassis.ems.EMSDemo;
import demo.network.chassis.propagation.AlarmPropagationDemo;
import demo.network.miscellaneous.autolayout.AutoLayoutDemo;
import demo.network.miscellaneous.cloudlayouter.CloudLayouterDemo;
import demo.network.miscellaneous.customlink.CustomLinkUIDemo;
import demo.network.miscellaneous.game.GreedySnakeDemo;
import demo.network.miscellaneous.instrument.InstrumentDemo;
import demo.network.miscellaneous.limitbound.LimitBoundDemo;
import demo.network.miscellaneous.magnifier.MagnifierDemo;
import demo.network.miscellaneous.map.MapDemo;
import demo.network.miscellaneous.mirror.MirrorDemo;
import demo.network.miscellaneous.office.OfficeDemo;
import demo.network.miscellaneous.population.PopulationDemo;
import demo.network.miscellaneous.shapeimage.ShapeImageDemo;
import demo.network.miscellaneous.shapelayout.ShapeLayoutDemo;
import demo.network.topo.attachment.AttachmentDemo;
import demo.network.topo.blinking.BlinkingDemo;
import demo.network.topo.bus.BusDemo;
import demo.network.topo.gif.GIFImageDemo;
import demo.network.topo.html.HTMLDemo;
import demo.network.topo.interaction.InteractionDemo;
import demo.network.topo.layer.LayerDemo;
import demo.network.topo.matrix.MatrixDemo;
import demo.network.topo.performance.PerformanceDemo;
import demo.network.topo.polyline.PolyLineDemo;
import demo.network.topo.pstn.PSTNDemo;
import demo.network.topo.route.RouteTraceDemo;
import demo.network.topo.subnetwork.SubNetworkDemo;
import demo.network.topo.titlegroup.TitleGroupDemo;
import demo.sheet.environment.EnvironmentDemo;
import demo.sheet.inherit.InheritPropertyDemo;
import demo.sheet.lookandfeel.LookAndFeelDemo;
import demo.sheet.nested.NestedCategoryDemo;
import demo.sheet.validate.ValidateValueDemo;
import demo.table.alarm.AlarmTableDemo;
import demo.table.explorer.ExplorerDemo;
import demo.table.legend.LegendDemo;
import demo.table.person.PersonDemo;
import demo.tree.file.FileTreeDemo;
import demo.tree.mode.TreeSelectionModeDemo;
import demo.tree.sort.TreeSortDemo;

public class DemoNodeFactory {
	
	public static class Category extends Node {
	    public Category(String name) {
	        setName(name);
	        setIcon("/demo/resource/images/component.png");
	    }
	}
	
    public static TDataBox box = null;
    public static Map updateMap = new HashMap();
    public static Map newMap = new HashMap();
    
    // add Category
    public static Node addCategory(String name) {
    	Node node = new Category(name);
        box.addElement(node);
        return node;
    }

    // add Category
    public static Node addCategory(Node parent, String name) {
        Node node = new Category(name);
        node.setParent(parent);
        box.addElement(node);
        return node;
    }

    // add Demo
    public static DemoNode addDemo(Element parent, Class demoClass) {
        DemoNode demo = new DemoNode(parent, demoClass);
        box.addElement(demo);
        return demo;
    }

    // create all node
    public static void createAll(TDataBox box) {
    	box.clear();
        DemoNodeFactory.box = box;

        //create category.
        Node dataBox = addCategory("DataBox");

        Node network = addCategory("Network");
        Node topo = addCategory(network, "Topology");
        Node chassis = addCategory(network, "Chassis");
        Node miscellaneous = addCategory(network, "Miscellaneous");
        Node tree = addCategory("Tree");
        Node sheet = addCategory("Sheet");
        Node table = addCategory("Table");
        Node list = addCategory("List");
        Node alarm = addCategory("Alarm");
        Node chart = addCategory("Chart");
        Node editor = addCategory("Editor");

        // update demo
        updateMap.put(CloudLayouterDemo.class, null);
                
        // new demo     
        newMap.put(LimitBoundDemo.class, null);            
        
        //set demos.
        addDemo(dataBox, MonitorPropertyDemo.class);
        addDemo(dataBox, MonitorElementDemo.class);
        addDemo(dataBox, ConversionDemo.class);
        
        addDemo(chassis, DynamicChassisDemo.class);   
        addDemo(chassis, AlarmPropagationDemo.class);
        addDemo(chassis, CustomGridDemo.class);
        addDemo(chassis, EMSDemo.class);
        
        addDemo(topo, PSTNDemo.class);
        addDemo(topo, HTMLDemo.class);
        addDemo(topo, AttachmentDemo.class);
        addDemo(topo, SubNetworkDemo.class);
        addDemo(topo, InteractionDemo.class);
        addDemo(topo, RouteTraceDemo.class);
        addDemo(topo, GIFImageDemo.class);
        addDemo(topo, BlinkingDemo.class);
        addDemo(topo, PolyLineDemo.class);
        addDemo(topo, BusDemo.class);
        addDemo(topo, MatrixDemo.class);
        addDemo(topo, PerformanceDemo.class);
        addDemo(topo, LayerDemo.class);
        addDemo(topo, TitleGroupDemo.class);
        
        addDemo(miscellaneous, LimitBoundDemo.class);
        addDemo(miscellaneous, MirrorDemo.class);
        addDemo(miscellaneous, ShapeLayoutDemo.class);
        addDemo(miscellaneous, InstrumentDemo.class);
        addDemo(miscellaneous, OfficeDemo.class);
        addDemo(miscellaneous, GreedySnakeDemo.class);
        addDemo(miscellaneous, AutoLayoutDemo.class);
        addDemo(miscellaneous, PopulationDemo.class);
        addDemo(miscellaneous, CustomLinkUIDemo.class);
        addDemo(miscellaneous, ShapeImageDemo.class);
        addDemo(miscellaneous, MagnifierDemo.class);
        addDemo(miscellaneous, MapDemo.class);
        addDemo(miscellaneous, CloudLayouterDemo.class);       
        
        addDemo(tree, TreeSortDemo.class);
        addDemo(tree, FileTreeDemo.class);   
        addDemo(tree, TreeSelectionModeDemo.class);    
        
        addDemo(sheet, InheritPropertyDemo.class);
        addDemo(sheet, NestedCategoryDemo.class);
        addDemo(sheet, ValidateValueDemo.class);
        addDemo(sheet, LookAndFeelDemo.class);
        addDemo(sheet, EnvironmentDemo.class);
        
        addDemo(table, LegendDemo.class);
        addDemo(table, PersonDemo.class);
        addDemo(table, AlarmTableDemo.class);
        addDemo(table, ExplorerDemo.class);
        
        addDemo(list, ChooseDemo.class);
        addDemo(list, QuickSearchDemo.class);
        
        addDemo(alarm, AlarmStatisticsDemo.class);
        addDemo(alarm, AlarmElementMappingDemo.class);

        addDemo(chart, CompositionDemo.class);
        addDemo(chart, PropertyDemo.class);
        addDemo(chart, GDPDemo.class);
        addDemo(chart, SurveyDemo.class);
        addDemo(chart, GoogleStockDemo.class);
        addDemo(chart, LoadingDemo.class);
        addDemo(chart, DialChartDemo.class);
        addDemo(chart, BubbleChartDemo.class);
        addDemo(chart, NetbeansSurveyDemo.class);
        addDemo(chart, RadarChartDemo.class);
        addDemo(chart, ChartAttachmentDemo.class);
        
        addDemo(editor, DrawingEditorDemo.class);
        addDemo(editor, PipeEditorDemo.class);
        addDemo(editor, ChassisEditorDemo.class);
        addDemo(editor, NetworkEditorDemo.class);

    }
}